package com.dongdongshop.service;

import com.dongdongshop.mapper.AdminMapper;
import com.dongdongshop.pojo.Admin;
import com.dongdongshop.pojo.AdminExample;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService
public class LoginServiceImpl implements LoginService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin selectByName(String name) {
        AdminExample ae = new AdminExample();
        AdminExample.Criteria criteria = ae.createCriteria();
        criteria.andNameEqualTo(name);
        List<Admin> admins = adminMapper.selectByExample(ae);
        Admin admin = admins.size() > 0 ? admins.get(0) : null;
        return admin;
    }
}
